package main

import (
	"asterisk_calls/collector"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/client_golang/prometheus/promhttp"
	"net/http"
	"time"
)

func main() {
	prometheus.MustRegister(collector.AstActiveCalls)
	prometheus.MustRegister(collector.AstActiveChannels)
	go func() {
		for {
			collector.AstActiveCalls.Set(collector.ActiveCalls())
			collector.AstActiveChannels.Set(collector.ActiveChannels())
			time.Sleep(1 * time.Second)
		}
	}()
	http.Handle("/metrics", promhttp.Handler())
	http.ListenAndServe(":8000", nil)
}
